package com.xiancheng;

import java.util.concurrent.*;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/2/25  10:48
 * 描述:
 */
public class TestXianchengchi {

    public static void main(String[] args) throws InterruptedException {

        ArrayBlockingQueue linkedBlockingDeque = new ArrayBlockingQueue(2);

        LinkedBlockingDeque<MyRunable> linkedBlockingDeque1=new LinkedBlockingDeque();

        ThreadPoolExecutor pool=new ThreadPoolExecutor(2,  //核心线程数
                                                            2,//最大线程数
                                                            5L,//线程的存活时间
                                                            TimeUnit.SECONDS, //线程存活时间的单位
                                                            linkedBlockingDeque,new MyRejectHandler(linkedBlockingDeque1));//工作队列



        for (int i=0;i<5;i++){
            pool.execute(new MyRunable());
        }

        while (true){
            pool.execute(linkedBlockingDeque1.take());
        }

    }

}
